package homeWork;

import java.util.Scanner;

public class homeWork2 {
    public static void main(String[] args) {
        System.out.println("请输入两个整数：");
        Scanner scanner = new Scanner(System.in);
        int num1 = scanner.nextInt();
        int num2 = scanner.nextInt();
        int gcd = findGCD(num1,num2);
        System.out.println(num1+ "和"+ num2 +"的最大公约数是：" + gcd);
    }
    //使用欧几里得算法求最大公约数
    public static int findGCD(int num1,int num2){
        while (num2 != 0){
            int temp = num2;
            num2 = num1 % num2;
            num1 = temp;
        }
        return num1;
    }
}
